using TripleA.Core.Interfaces;
using TripleA.Core.Interfaces.Entities;

namespace TripleA.Core.Extensions.FileSystem
{
    public static partial class FileSystemExtensions
    {
        public static IPipelineConfig<T> CleanFolder<T>(this IPipelineConfig<T> config, string folder)
            where T : Context
        {
            config.RunStep(new CleanFolderStep<T>(folder));
            return config;
        }
        
        /// <summary>
        /// This will copy the CONTENT of the <paramref name="sourceFolder"/> (files and sub-folders) to the 
        /// <paramref name="targetFolder"/> location.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="config"></param>
        /// <param name="sourceFolder"></param>
        /// <param name="targetFolder"></param>
        /// <returns></returns>
        public static IPipelineConfig<T> CloneFolderContent<T>(this IPipelineConfig<T> config, string sourceFolder, string targetFolder)
            where T : Context
        {
            config.RunStep(new CloneFolderContentStep<T>(sourceFolder, targetFolder));
            return config;
        }
        
        /// <summary>
        /// This will check that the specified folder has no content
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="config"></param>
        /// <param name="targetFolder"></param>
        /// <returns></returns>
        public static IPipelineConfig<T> IsFolderEmpty<T>(this IPipelineConfig<T> config, string targetFolder)
            where T : Context
        {
            config.RunStep(new IsFolderEmptyStep<T>(targetFolder));
            return config;
        }
        
        /// <summary>
        /// This will check that the specified folder has the specified file
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="config"></param>
        /// <param name="folder"></param>
        /// <param name="filename"></param>
        /// <returns></returns>
        public static IPipelineConfig<T> FolderContainsFile<T>(this IPipelineConfig<T> config, string folder, string filename)
            where T : Context
        {
            config.RunStep(new FolderContainsFileStep<T>(folder, filename));
            return config;
        }

        /// <summary>
        /// This will check that the specified folder does not contain the specified file
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="config"></param>
        /// <param name="folder"></param>
        /// <param name="filename"></param>
        /// <returns></returns>
        public static IPipelineConfig<T> FolderDoesNotContainFile<T>(this IPipelineConfig<T> config, string folder, string filename)
            where T : Context
        {
            config.RunStep(new FolderContainsFileStep<T>(folder, filename, false));
            return config;
        }
    }
}